/*
 * CopyRight(C) Kenbin
 */

#ifndef LWS_CSEGMENT_INCLUDED
#define LWS_CSEGMENT_INCLUDED

#include "lws_wordgraph.h"
#include "lws_basicseg.h"
#include "lws_recog.h"
#include "lws_postag.h"

namespace LWS {

    class CSegment
    {
	public:
	    CSegment(CTrieDict *dict, CHmm *person_hmm, CHmm *location_hmm, CHmm *postag_hmm, int option);
	    ~CSegment();

	    bool Segment(const char *text);

	    int WordCount() { return m_word_count; }
	    vector<char *>& WordPtrs() { return m_word_ptrs; }
	    vector<short>& BestPosTags() { return m_postag.BestStates(); }
	    set<int>& WordSpecTags() { return m_word_spectags; }
	    vector<int>& WordPositions() { return m_word_positions; }

	private:
	    void preprocess(char *text);

	    char *m_text;
	    int m_text_size;
	    char *m_seg_text;
	    int m_seg_text_size;

	    bool m_is_upper_to_lower;
	    bool m_is_gb_to_ascii;
	    bool m_is_atom_recog;
	    bool m_is_person_recog;
	    bool m_is_split_cn_person;
	    bool m_is_location_recog;
	    bool m_is_numtime_recog;
	    bool m_is_postag;

	    CWordGraph m_wordgraph;
	    CBasicSeg m_basicseg;

	    CPersonRecog m_person_recog;
	    CLocationRecog m_location_recog;
	    CNumTimeRecog m_numtime_recog;
	    CPosTag m_postag;

	    int m_word_count;
	    vector<char *> m_word_ptrs;
	    set<int> m_word_spectags;
	    vector<int> m_word_positions;
    };

};

#endif
